<?php

namespace App\Http\Middleware;

use App\Modules\System\Services\VisitorHistoryService;
use Closure;

class BarberVisitor
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
	    // 写数据操作
	    if(!empty($request->store_id) && !empty($request->barber_id) && !empty($request->source) && !empty($request->link_name)){
		    VisitorHistoryService::createOrUpdateVisitorByBarber($request->barber_id,$request->store_id,$request->source,$request->link_name);
	    }
        return $next($request);
    }
}
